<template>
  <div class="containerDetails">
    <div class="Details-header">
      <div class="header-item header-left header-img"><img src="../assets/icon/left.png" alt=""></div>
      <div class="header-item header-title">商品详情</div>
      <div class="header-item header-right header-img"><img src="../assets/icon/share.png" alt=""></div>
    </div>
    <div class="Details-content">
      <div class="swiper-container">
        <div class="swiper-wrapper">
          <div class="swiper-slide" v-for="item in commodityData.prodImage">
            <img :src="item" alt="">
          </div>
        </div>
        <!-- 如果需要分页器 -->
        <!--<div class="swiper-pagination"></div>-->
      </div>
      <ul class="content-describe">
        <li class="describe_item ">
          <p class="item_sup">{{commodityData.prodSupTitle}}</p>
          <p class="item_coupon">该商品最高可以使用30元优惠券</p>
          <p class="item_price">￥{{commodityData.currentPrice}}</p>
        </li>
        <li class="describe_item item_Quality"><img src="../assets/icon/Qualitygoods.png" alt="">
          <span>100%正品保证</span>
        </li>
        <li class="describe_item item_address">
          <div class="describe_item_left">
            <span>配送至</span><span class="address_color">北京顺义区光明街道</span>
          </div>
          <div class="describe_item_right">
            <img src="../assets/icon/right.png" alt="">
          </div>
          <div class="item_address-bottom">
             <span class="Remarks">有货</span>
          </div>
        </li>
        <li class="item_Number">
          <span>已选</span>
          <span>1件</span>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
  import 'swiper/dist/css/swiper.css'
  import Swiper from 'swiper/dist/js/swiper';

  export default {
    name: "commoditydetails",
    data() {
      return {
        commodityData: ''
      }
    },
    methods: {
      initSwiper() {
        this.swiper = new Swiper('.swiper-container', {
          /* direction: 'vertical', // 垂直切换选项*/
          loop: true, // 循环模式选项
          speed: 900,
          observer: false,//修改swiper自己或子元素时，自动初始化swiper
          observeParents: false,//修改swiper的父元素时，自动初始化swiper
          // 如果需要分页器
          /* pagination: {
             el: '.swiper-pagination',
           },*/
        });
      }
    },
    mounted() {
      console.log(this.$route.params.name);
      this.commodityData = this.$route.params.name;
      console.log(this.commodityData.prodImage[0]);
      this.$nextTick(() => {  // 下一个UI帧再初始化swiper
        this.initSwiper();
      });
    },
  }
</script>

<style lang="scss">
  * {
    margin: 0;
    padding: 0;
  }

  .containerDetails {
    position: absolute;
    background: #f5f5f5;
    .Details-header {
      width: 100vw;
      height: 100px;
      background: #fff;
      position: fixed;
      z-index: 100;
      top: 0;
    }
    .header-item {
      display: inline-block;
      width: 25%;
      line-height: 100px;
      box-sizing: border-box;
      float: left;
      vertical-align: middle;
    }
    .header-title {
      width: 50%;
    }
    .header-left {
      text-align: left;
      img {
        display: inline-block;
        padding-left: 30px;
        width: 40px;
        height: 40px;
        line-height: 100px;
        vertical-align: middle;
      }
    }
    .header-right {
      text-align: right;
      img {
        padding-right: 30px;
        display: inline-block;
        width: 40px;
        height: 40px;
        line-height: 100px;
        vertical-align: middle;
      }
    }
    .header-title {
      text-align: center;
      font-size: 36px;
      color: #666;
      vertical-align: middle;
    }
    .Details-content {
      margin-top: 114px;
      width: 100vw;
      height: 100vh;
      overflow: hidden;
      .swiper-wrapper {
        img {
          width: 100vw;
          height: 750px;
        }
      }
      .content-describe{
        margin-top: 40px;
        display: inline-block;
        width: 100vw;
        height: 490px;
        background: #fff;
        overflow: hidden;
        li{
          display: inline-block;
          width: 100vw;
          &::after{
            content: '';
            display: block;
            height: 1px;
            border-bottom: 1px solid #c8c8cb;
            vertical-align: middle;
          }
          p{
            padding-left: 30px;
          }
          .item_sup{
            margin-top: 20px;
            line-height: 50px;
            font-size: 32px;
            color: #000;
            padding-left:40px;
          }
          .item_coupon{
            font-size: 28px;
            color: #fa3f3f;
            line-height: 40px;
          }
          .item_price{
            color: #666;
            font-size: 30px;
            line-height: 70px;
          }
        }
        .item_Quality{
          line-height: 80px;
          box-sizing: border-box;
          img{
            display: inline-block;
            width: 40px;
            height: 40px;
            padding-left: 30px;
            vertical-align: middle;
          }
          span{
            margin-left: 20px;
            display: inline-block;
            font-size: 30px;
            color: #666;
            vertical-align: middle;
          }
        }
        .item_address{
          height: 146px;
            span{
              display: inline-block;
              margin-top: 20px;
              font-size: 30px;
              margin-left: 30px;
              color: #666;
            }
          .describe_item_left{
            float: left;
            height: 60px;
            box-sizing: border-box;
            width: 80%;
            display: inline-block;

          }
          .describe_item_right {
            float: left;
            line-height: 60px;
            box-sizing: border-box;
            width: 20%;
            display: inline-block;
            text-align: right;
            img{
              width: 40px;
              height: 40px;
              vertical-align: middle;
              display: inline-block;
            }
          }
            .address_color{
              color: #000;
          }
          .item_address-bottom{
            height: 86px;
            width: 100vw;
                .Remarks{
                  height: 42px;
                  width: 80px;
                  margin-top: 20px;
                  border-radius: 5px;
                  text-align: center;
                  display: inline-block;
                  font-size: 30px;
                  box-sizing: border-box;
                  color: #fa9549;
                  margin-left: 150px;
                  border: 2px solid #fa9549;
                }
          }
        }
        .item_Number{
          line-height: 80px;
          box-sizing: border-box;
          span{
            display: inline-block;
            font-size: 30px;
            margin-left: 30px;
            color: #666;
            line-height: 80px;
          }
        }
      }
    }
  }
</style>
